package com.zj.osm.utils.db_utils;

import android.annotation.SuppressLint;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.zj.osm.model.pojo.ModuleType;
import com.zj.osm.utils.SQLiteDatabaseUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <pre>
 *     author : luhenchang
 *     e-mail : 1276998208@qq.com
 *     time   : 2019/12/03
 *     desc   : 版权所有
 *     version: 1.0
 * </pre>
 */
public class ModuleTypeUtils {
    private static final String SELECT_FROM_MODULE_TYPE = "select * from ModuleType mt where mt.ParentKey = '50000GT' and mt.State = '100'";
    private SQLiteDatabase sqLiteDatabase = SQLiteDatabaseUtils.getInstance().getSQLiteDatabase();
    private static final ModuleTypeUtils ourInstance = new ModuleTypeUtils();
    public static ModuleTypeUtils getInstance() {
        return ourInstance;
    }
    private ModuleTypeUtils() {

    }
    /**
     * @AddProjectActivity 获取杆型的数据
     * @return moduleType
     */
    public List<ModuleType> getModuleType() {
        List<ModuleType> moduleTypes = new ArrayList<>();
        @SuppressLint("Recycle") Cursor cursor = sqLiteDatabase.rawQuery(SELECT_FROM_MODULE_TYPE, null);//此处的db是表名，name是列名
        while (cursor.moveToNext()) {
            ModuleType moduleType = new ModuleType();
            moduleType.setModuleTypeID(cursor.getString(0));
            moduleType.setName(cursor.getString(1));
            moduleType.setModuleTypeKey(cursor.getString(2));
            moduleTypes.add(moduleType);
        }
        cursor.close();
        return moduleTypes;
    }







}
